
import React, { Component } from 'react'
import { SET_INFO} from './store/actions/auth'
import { connect } from 'react-redux'
import Home from './pages/home'
import Login from './pages/login'

class App extends Component {
  render() {
    console.log(this.props)
    return (
      <div className="App">
        {this.props.info.id? <Home/>: <Login/>}
      </div>
    )
  }
}

function mapStateToProps(state){
  return {
    info: state.auth.info
  }
}

function mapDispatchToProops(dispatch){
  return {
    setInfo: (info) =>  dispatch({
        type:SET_INFO,
        info
    })
  }
}

App = connect(mapStateToProps, mapDispatchToProops)(App)
export default App;
